module.exports = function(tplData) {
  let files = tplData.htmlWebpackPlugin.files;
  console.log(files);
  let scripts = [], styles = [];
  // 脚本预加载，暂时在chrome中实现，Firefox暂时不做
  for (let c in files.chunks) {
    let e = files.chunks[c];
    scripts.push(`<link rel='prefetch' href="${e.entry}" />`);
  }
  // 样式先加载
  for (let c of files.css) {
    styles.push(`<link rel='subresource' href="${c}" />`);
  }
  return `<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <!-- DNS配置 -->
    <meta http-equiv='x-dns-prefetch-control' content='on'>
    <link rel='dns-prefetch' href='http://cdn.bootcss.com'>
    <link rel='prerender' href='/index/thumb'>
    <link rel='prerender' href='/index/star'>
    <!-- end DNS配置 -->
    <title>{% block title %}My Site{% endblock %}</title>
    {% block headstyles %}
    ${styles.join('')}
    ${scripts.join('')}
    {% endblock %}
</head>
<body>
<div class="ad">
我是广告...
</div>
<p>Go to <a href="javascript:void(0);" data-href="/index/thumb" data-pjax="true">thumb</a>、<a href="javascript:void(0);" data-href="/index/star" data-pjax="true">star</a>.</p>
<div class="container" id="pjax-container">
</div>
<div class="container" id="pjax-container">
{% block content %}
{% endblock %}
</div>
{% block bottomscipts %}
<script src="http://cdn.bootcss.com/lazyload/2.0.3/lazyload.js"></script>
<script>
  var list = [
    'http://cdn.bootcss.com/jquery/2.2.4/jquery.js',
    'http://cdn.bootcss.com/axios/0.14.0/axios.min.js',
    'http://cdn.bootcss.com/lodash.js/4.17.4/lodash.min.js',
    'http://cdn.bootcss.com/jquery.pjax/1.9.6/jquery.pjax.js'
  ];
  LazyLoad.js(list, function () {
    console.log('public js, etc.jquery, has been loaded');
    // $(document).pjax('[data-pjax] a, a[data-pjax]', '#pjax-container');
    if ($.support.pjax) {
      var $container = $('#pjax-container');
      $(document).on('click', 'a[data-pjax]', function(event) {
        // $.pjax.click(event, {container: $container})
        $.pjax({
          url: $(this).data('href'),
          container: $container
        });
      })
    }
  });
</script>
{% endblock %}
</body>
</html>`
}